var a = require("../../../../@babel/runtime/helpers/defineProperty"), t = getApp();

Page({
    data: {
        keyword: "",
        activeName: 0,
        dataList: [],
        titleArr: [],
        isLoadMore: !0
    },
    onLoad: function(a) {
        this.init();
    },
    init: function() {
        this.isLoadMore = !0, this.setData({
            titleArr: [ {
                id: 0,
                name: "全部",
                url: "refund.list.index"
            }, {
                id: 1,
                name: "待处理",
                url: "refund.list.wait"
            }, {
                id: 2,
                name: "已完成",
                url: "refund.list.complete"
            }, {
                id: 3,
                name: "驳回/关闭",
                url: "refund.list.cancel"
            } ]
        }), this.setNewArr();
    },
    setNewArr: function() {
        var a = [];
        this.data.titleArr.forEach(function(t, e) {
            a.push({
                url: t.url,
                isLoadMore: !0,
                loading: !1,
                finished: !1,
                page: 1,
                total_page: 0,
                list: []
            });
        }), this.setData({
            dataList: a
        }), this.handleClick();
    },
    handleClick: function(e) {
        var i = this;
        e && this.setData({
            activeName: e.detail.name
        });
        var d = this.options, s = d.refund_id, o = void 0 === s ? "" : s, n = d.order_goods_id, r = void 0 === n ? "" : n, c = {
            page: 1,
            sn: this.data.keyword,
            refund_id: o,
            order_goods_id: r
        }, l = t.getNetAddresss(this.data.dataList[this.data.activeName].url);
        t._getNetWork({
            url: l,
            data: c,
            success: function(t) {
                var e = t.data;
                1 == e.result ? (i.setData(a({}, "dataList[" + i.data.activeName + "].list", e.data.data)), 
                i.data.isLoadMore = !0, i.data.dataList[i.data.activeName].isLoadMore = !0, i.data.dataList[i.data.activeName].page = 1, 
                i.data.dataList[i.data.activeName].total_page = e.data.last_page) : wx.showToast({
                    icon: "none",
                    title: e.msg,
                    duration: 1e3
                });
            },
            fail: function(a) {
                console.log(a);
            }
        });
    },
    onChangeKey: function(a) {
        this.setData({
            keyword: a.detail
        });
    },
    onSearch: function() {
        this.handleClick();
    },
    toUrl: function(a) {
        var t = a.currentTarget.dataset.item, e = "";
        40 == t.plugin_id && 1 == t.refund_type && 6 == t.status ? e = "/packageB/member/OrderReturnSure/OrderReturnSure?id=" + t.order.id : (144 === t.plugin_id && (e = "/packageF/consumption/refundProcess/refundProcess?refundId=".concat(t.id)), 
        144 !== t.plugin_id && (e = "/packageD/member/myOrder/Aftersales/Aftersales?refund_id=" + t.id + "&pluginid=" + t.plugin_id)), 
        wx.navigateTo({
            url: e
        });
    },
    _getMoreData: function() {
        var e = this;
        if (this.data.dataList[this.data.activeName].isLoadMore = !1, !(this.data.dataList[this.data.activeName].page >= this.data.dataList[this.data.activeName].total_page)) {
            this.data.dataList[this.data.activeName].page = this.data.dataList[this.data.activeName].page + 1;
            var i = this.options, d = i.refund_id, s = void 0 === d ? "" : d, o = i.order_goods_id, n = void 0 === o ? "" : o, r = {
                page: this.data.dataList[this.data.activeName].page,
                sn: this.data.keyword,
                refund_id: s,
                order_goods_id: n
            }, c = t.getNetAddresss("plugin.hand-sign-protocol.frontend.controllers.protocol.index");
            t._getNetWork({
                url: c,
                data: r,
                success: function(t) {
                    var i = t.data;
                    if (1 == i.result) {
                        var d, s = i.data.data;
                        e.setData((a(d = {}, "dataList[" + e.data.activeName + "].isLoadMore", !0), a(d, "dataList[" + e.data.activeName + "].list", e.data.dataList[e.data.activeName].list.concat(s)), 
                        d));
                    } else {
                        var o;
                        e.setData((a(o = {}, "dataList[" + e.data.activeName + "].isLoadMore", !1), a(o, "dataList[" + e.data.activeName + "].page", e.data.dataList[e.data.activeName].page - 1), 
                        o));
                    }
                },
                fail: function(a) {
                    console.log(a);
                }
            });
        }
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.dataList[this.data.activeName].isLoadMore ? this._getMoreData() : console.log("没有更多数据");
    },
    onShareAppMessage: function() {}
});